#include "ConfigEmoDiag.h"

BEGIN_EVENT_TABLE( ConfigEmoDiag, wxDialog )

	EVT_BUTTON(wxOk,ConfigEmoDiag::OkButton)
	EVT_BUTTON(wxCancel,ConfigEmoDiag::CancelButton)
END_EVENT_TABLE()

ConfigEmoDiag::ConfigEmoDiag(wxWindow* parent,int *channels, bool *configured):EmotivConfig(parent)
{
	ConfDone = configured;
	myCh = channels;
}

ConfigEmoDiag::~ConfigEmoDiag(void)
{
}

void ConfigEmoDiag::OkButton(wxCommandEvent& event)
{
	//Read the value of the GUI and reinitialize the device.
	if (AF3->GetValue())
		myCh[0]=1;
	else
		myCh[0]=0;
	if (F7->GetValue())
		myCh[1]=1;
	else
		myCh[1]=0;
	if (F3->GetValue())
		myCh[2]=1;
	else
		myCh[2]=0;
	if (FC5->GetValue())
		myCh[3]=1;
	else
		myCh[3]=0;
	if (T7->GetValue())
		myCh[4]=1;
	else
		myCh[4]=0;
	if (P7->GetValue())
		myCh[5]=1;
	else
		myCh[5]=0;
	if (O1->GetValue())
		myCh[6]=1;
	else
		myCh[6]=0;
	if (O2->GetValue())
		myCh[7]=1;
	else
		myCh[7]=0;
	if (P8->GetValue())
		myCh[8]=1;
	else
		myCh[8]=0;
	if (T8->GetValue())
		myCh[9]=1;
	else
		myCh[9]=0;
	if (FC6->GetValue())
		myCh[10]=1;
	else
		myCh[10]=0;
	if (F4->GetValue())
		myCh[11]=1;
	else
		myCh[11]=0;
	if (F8->GetValue())
		myCh[12]=1;
	else
		myCh[12]=0;
	if (AF4->GetValue())
		myCh[13]=1;
	else
		myCh[13]=0;
	if (GyroX->GetValue())
		myCh[14]=1;
	else
		myCh[14]=0;
	if (GyroY->GetValue())
		myCh[15]=1;
	else
		myCh[15]=0;

	*ConfDone = true;
	this->Close();

}

void ConfigEmoDiag::CancelButton(wxCommandEvent& event)
{
	//Close and do nothing
	*ConfDone = false;
	this->Close();
}
